<template>
  <div class="channel-popup-wrap" v-show="isShow">
    <div class="select">
      <span>请选择</span>
      <div class="arrow-up" @click="isShow = false">
        <van-icon name="arrow-up" color="#666666" />
      </div>
    </div>
    <ul class="select-channel-list">
      <li
        v-for="(item, index) in channelList"
        :key="index"
        :class="{ active: curTabIndex == index }"
        @click="handleSelectTab(index)"
      >
        {{ item.name }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'channelPopup',
  props: {
    channelList: {
      type: Array,
      default: () => []
    },
    curTabIndex: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      isShow: false
    };
  },
  methods: {
    showPopup() {
      this.isShow = true;
    },
    closePopup() {
      this.isShow = false;
    },
    handleSelectTab(index) {
      this.$emit('selectTab', index);
      this.closePopup();
    }
  }
};
</script>

<style lang="scss" scoped>
.channel-popup-wrap {
  width: 100%;
  height: 100%;
  position: fixed;
  z-index: 2028;
  left: 0;
  top: 0;
  background-color: rgba($color: #000000, $alpha: 0.6);
  .select {
    width: 100%;
    height: 38px;
    line-height: 38px;
    background-color: #ffffff;
    text-align: left;
    padding-left: 16px;
    box-sizing: border-box;
    position: relative;
    font-family: PingFangSC-Regular;
    color: #999999;
    font-size: 14px;

    .arrow-up {
      background-color: #ffffff;
      position: absolute;
      right: 0;
      width: 38px;
      height: 38px;
      display: flex;
      align-items: center;
      justify-content: space-around;
      top: 0;
      z-index: 2;
    }

    &::after {
      width: 20px;
      height: 24px;
      content: '';
      display: block;
      position: absolute;
      right: 17px;
      top: 9px;
      box-shadow: -3px 0px 10px #c8c9cc;
      z-index: 1;
    }
  }

  .select-channel-list {
    background-color: #f5f5f5;
    color: #666666;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    padding-top: 20px;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    border-radius: 0px 0px 6px 6px;

    li {
      margin-bottom: 24px;
      width: 33.3%;
      text-align: center;
      font-size: 14px;
    }

    .active {
      color: #e62525;
    }
  }
}
</style>
